function q(g) {
  return g && g.__esModule && Object.prototype.hasOwnProperty.call(g, "default") ? g.default : g;
}
var E = { exports: {} }, R = E.exports, O;
function U() {
  return O || (O = 1, function(g, m) {
    (function(i, f) {
      f(g);
    })(typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : R, function(i) {
      if (!(globalThis.chrome && globalThis.chrome.runtime && globalThis.chrome.runtime.id))
        throw new Error("This script should only be loaded in a browser extension.");
      if (globalThis.browser && globalThis.browser.runtime && globalThis.browser.runtime.id)
        i.exports = globalThis.browser;
      else {
        const f = "The message port closed before a response was received.", p = (u) => {
          const v = {
            alarms: {
              clear: {
                minArgs: 0,
                maxArgs: 1
              },
              clearAll: {
                minArgs: 0,
                maxArgs: 0
              },
              get: {
                minArgs: 0,
                maxArgs: 1
              },
              getAll: {
                minArgs: 0,
                maxArgs: 0
              }
            },
            bookmarks: {
              create: {
                minArgs: 1,
                maxArgs: 1
              },
              get: {
                minArgs: 1,
                maxArgs: 1
              },
              getChildren: {
                minArgs: 1,
                maxArgs: 1
              },
              getRecent: {
                minArgs: 1,
                maxArgs: 1
              },
              getSubTree: {
                minArgs: 1,
                maxArgs: 1
              },
              getTree: {
                minArgs: 0,
                maxArgs: 0
              },
              move: {
                minArgs: 2,
                maxArgs: 2
              },
              remove: {
                minArgs: 1,
                maxArgs: 1
              },
              removeTree: {
                minArgs: 1,
                maxArgs: 1
              },
              search: {
                minArgs: 1,
                maxArgs: 1
              },
              update: {
                minArgs: 2,
                maxArgs: 2
              }
            },
            browserAction: {
              disable: {
                minArgs: 0,
                maxArgs: 1,
                fallbackToNoCallback: !0
              },
              enable: {
                minArgs: 0,
                maxArgs: 1,
                fallbackToNoCallback: !0
              },
              getBadgeBackgroundColor: {
                minArgs: 1,
                maxArgs: 1
              },
              getBadgeText: {
                minArgs: 1,
                maxArgs: 1
              },
              getPopup: {
                minArgs: 1,
                maxArgs: 1
              },
              getTitle: {
                minArgs: 1,
                maxArgs: 1
              },
              openPopup: {
                minArgs: 0,
                maxArgs: 0
              },
              setBadgeBackgroundColor: {
                minArgs: 1,
                maxArgs: 1,
                fallbackToNoCallback: !0
              },
              setBadgeText: {
                minArgs: 1,
                maxArgs: 1,
                fallbackToNoCallback: !0
              },
              setIcon: {
                minArgs: 1,
                maxArgs: 1
              },
              setPopup: {
                minArgs: 1,
                maxArgs: 1,
                fallbackToNoCallback: !0
              },
              setTitle: {
                minArgs: 1,
                maxArgs: 1,
                fallbackToNoCallback: !0
              }
            },
            browsingData: {
              remove: {
                minArgs: 2,
                maxArgs: 2
              },
              removeCache: {
                minArgs: 1,
                maxArgs: 1
              },
              removeCookies: {
                minArgs: 1,
                maxArgs: 1
              },
              removeDownloads: {
                minArgs: 1,
                maxArgs: 1
              },
              removeFormData: {
                minArgs: 1,
                maxArgs: 1
              },
              removeHistory: {
                minArgs: 1,
                maxArgs: 1
              },
              removeLocalStorage: {
                minArgs: 1,
                maxArgs: 1
              },
              removePasswords: {
                minArgs: 1,
                maxArgs: 1
              },
              removePluginData: {
                minArgs: 1,
                maxArgs: 1
              },
              settings: {
                minArgs: 0,
                maxArgs: 0
              }
            },
            commands: {
              getAll: {
                minArgs: 0,
                maxArgs: 0
              }
            },
            contextMenus: {
              remove: {
                minArgs: 1,
                maxArgs: 1
              },
              removeAll: {
                minArgs: 0,
                maxArgs: 0
              },
              update: {
                minArgs: 2,
                maxArgs: 2
              }
            },
            cookies: {
              get: {
                minArgs: 1,
                maxArgs: 1
              },
              getAll: {
                minArgs: 1,
                maxArgs: 1
              },
              getAllCookieStores: {
                minArgs: 0,
                maxArgs: 0
              },
              remove: {
                minArgs: 1,
                maxArgs: 1
              },
              set: {
                minArgs: 1,
                maxArgs: 1
              }
            },
            devtools: {
              inspectedWindow: {
                eval: {
                  minArgs: 1,
                  maxArgs: 2,
                  singleCallbackArg: !1
                }
              },
              panels: {
                create: {
                  minArgs: 3,
                  maxArgs: 3,
                  singleCallbackArg: !0
                },
                elements: {
                  createSidebarPane: {
                    minArgs: 1,
                    maxArgs: 1
                  }
                }
              }
            },
            downloads: {
              cancel: {
                minArgs: 1,
                maxArgs: 1
              },
              download: {
                minArgs: 1,
                maxArgs: 1
              },
              erase: {
                minArgs: 1,
                maxArgs: 1
              },
              getFileIcon: {
                minArgs: 1,
                maxArgs: 2
              },
              open: {
                minArgs: 1,
                maxArgs: 1,
                fallbackToNoCallback: !0
              },
              pause: {
                minArgs: 1,
                maxArgs: 1
              },
              removeFile: {
                minArgs: 1,
                maxArgs: 1
              },
              resume: {
                minArgs: 1,
                maxArgs: 1
              },
              search: {
                minArgs: 1,
                maxArgs: 1
              },
              show: {
                minArgs: 1,
                maxArgs: 1,
                fallbackToNoCallback: !0
              }
            },
            extension: {
              isAllowedFileSchemeAccess: {
                minArgs: 0,
                maxArgs: 0
              },
              isAllowedIncognitoAccess: {
                minArgs: 0,
                maxArgs: 0
              }
            },
            history: {
              addUrl: {
                minArgs: 1,
                maxArgs: 1
              },
              deleteAll: {
                minArgs: 0,
                maxArgs: 0
              },
              deleteRange: {
                minArgs: 1,
                maxArgs: 1
              },
              deleteUrl: {
                minArgs: 1,
                maxArgs: 1
              },
              getVisits: {
                minArgs: 1,
                maxArgs: 1
              },
              search: {
                minArgs: 1,
                maxArgs: 1
              }
            },
            i18n: {
              detectLanguage: {
                minArgs: 1,
                maxArgs: 1
              },
              getAcceptLanguages: {
                minArgs: 0,
                maxArgs: 0
              }
            },
            identity: {
              launchWebAuthFlow: {
                minArgs: 1,
                maxArgs: 1
              }
            },
            idle: {
              queryState: {
                minArgs: 1,
                maxArgs: 1
              }
            },
            management: {
              get: {
                minArgs: 1,
                maxArgs: 1
              },
              getAll: {
                minArgs: 0,
                maxArgs: 0
              },
              getSelf: {
                minArgs: 0,
                maxArgs: 0
              },
              setEnabled: {
                minArgs: 2,
                maxArgs: 2
              },
              uninstallSelf: {
                minArgs: 0,
                maxArgs: 1
              }
            },
            notifications: {
              clear: {
                minArgs: 1,
                maxArgs: 1
              },
              create: {
                minArgs: 1,
                maxArgs: 2
              },
              getAll: {
                minArgs: 0,
                maxArgs: 0
              },
              getPermissionLevel: {
                minArgs: 0,
                maxArgs: 0
              },
              update: {
                minArgs: 2,
                maxArgs: 2
              }
            },
            pageAction: {
              getPopup: {
                minArgs: 1,
                maxArgs: 1
              },
              getTitle: {
                minArgs: 1,
                maxArgs: 1
              },
              hide: {
                minArgs: 1,
                maxArgs: 1,
                fallbackToNoCallback: !0
              },
              setIcon: {
                minArgs: 1,
                maxArgs: 1
              },
              setPopup: {
                minArgs: 1,
                maxArgs: 1,
                fallbackToNoCallback: !0
              },
              setTitle: {
                minArgs: 1,
                maxArgs: 1,
                fallbackToNoCallback: !0
              },
              show: {
                minArgs: 1,
                maxArgs: 1,
                fallbackToNoCallback: !0
              }
            },
            permissions: {
              contains: {
                minArgs: 1,
                maxArgs: 1
              },
              getAll: {
                minArgs: 0,
                maxArgs: 0
              },
              remove: {
                minArgs: 1,
                maxArgs: 1
              },
              request: {
                minArgs: 1,
                maxArgs: 1
              }
            },
            runtime: {
              getBackgroundPage: {
                minArgs: 0,
                maxArgs: 0
              },
              getPlatformInfo: {
                minArgs: 0,
                maxArgs: 0
              },
              openOptionsPage: {
                minArgs: 0,
                maxArgs: 0
              },
              requestUpdateCheck: {
                minArgs: 0,
                maxArgs: 0
              },
              sendMessage: {
                minArgs: 1,
                maxArgs: 3
              },
              sendNativeMessage: {
                minArgs: 2,
                maxArgs: 2
              },
              setUninstallURL: {
                minArgs: 1,
                maxArgs: 1
              }
            },
            sessions: {
              getDevices: {
                minArgs: 0,
                maxArgs: 1
              },
              getRecentlyClosed: {
                minArgs: 0,
                maxArgs: 1
              },
              restore: {
                minArgs: 0,
                maxArgs: 1
              }
            },
            storage: {
              local: {
                clear: {
                  minArgs: 0,
                  maxArgs: 0
                },
                get: {
                  minArgs: 0,
                  maxArgs: 1
                },
                getBytesInUse: {
                  minArgs: 0,
                  maxArgs: 1
                },
                remove: {
                  minArgs: 1,
                  maxArgs: 1
                },
                set: {
                  minArgs: 1,
                  maxArgs: 1
                }
              },
              managed: {
                get: {
                  minArgs: 0,
                  maxArgs: 1
                },
                getBytesInUse: {
                  minArgs: 0,
                  maxArgs: 1
                }
              },
              sync: {
                clear: {
                  minArgs: 0,
                  maxArgs: 0
                },
                get: {
                  minArgs: 0,
                  maxArgs: 1
                },
                getBytesInUse: {
                  minArgs: 0,
                  maxArgs: 1
                },
                remove: {
                  minArgs: 1,
                  maxArgs: 1
                },
                set: {
                  minArgs: 1,
                  maxArgs: 1
                }
              }
            },
            tabs: {
              captureVisibleTab: {
                minArgs: 0,
                maxArgs: 2
              },
              create: {
                minArgs: 1,
                maxArgs: 1
              },
              detectLanguage: {
                minArgs: 0,
                maxArgs: 1
              },
              discard: {
                minArgs: 0,
                maxArgs: 1
              },
              duplicate: {
                minArgs: 1,
                maxArgs: 1
              },
              executeScript: {
                minArgs: 1,
                maxArgs: 2
              },
              get: {
                minArgs: 1,
                maxArgs: 1
              },
              getCurrent: {
                minArgs: 0,
                maxArgs: 0
              },
              getZoom: {
                minArgs: 0,
                maxArgs: 1
              },
              getZoomSettings: {
                minArgs: 0,
                maxArgs: 1
              },
              goBack: {
                minArgs: 0,
                maxArgs: 1
              },
              goForward: {
                minArgs: 0,
                maxArgs: 1
              },
              highlight: {
                minArgs: 1,
                maxArgs: 1
              },
              insertCSS: {
                minArgs: 1,
                maxArgs: 2
              },
              move: {
                minArgs: 2,
                maxArgs: 2
              },
              query: {
                minArgs: 1,
                maxArgs: 1
              },
              reload: {
                minArgs: 0,
                maxArgs: 2
              },
              remove: {
                minArgs: 1,
                maxArgs: 1
              },
              removeCSS: {
                minArgs: 1,
                maxArgs: 2
              },
              sendMessage: {
                minArgs: 2,
                maxArgs: 3
              },
              setZoom: {
                minArgs: 1,
                maxArgs: 2
              },
              setZoomSettings: {
                minArgs: 1,
                maxArgs: 2
              },
              update: {
                minArgs: 1,
                maxArgs: 2
              }
            },
            topSites: {
              get: {
                minArgs: 0,
                maxArgs: 0
              }
            },
            webNavigation: {
              getAllFrames: {
                minArgs: 1,
                maxArgs: 1
              },
              getFrame: {
                minArgs: 1,
                maxArgs: 1
              }
            },
            webRequest: {
              handlerBehaviorChanged: {
                minArgs: 0,
                maxArgs: 0
              }
            },
            windows: {
              create: {
                minArgs: 0,
                maxArgs: 1
              },
              get: {
                minArgs: 1,
                maxArgs: 2
              },
              getAll: {
                minArgs: 0,
                maxArgs: 1
              },
              getCurrent: {
                minArgs: 0,
                maxArgs: 1
              },
              getLastFocused: {
                minArgs: 0,
                maxArgs: 1
              },
              remove: {
                minArgs: 1,
                maxArgs: 1
              },
              update: {
                minArgs: 2,
                maxArgs: 2
              }
            }
          };
          if (Object.keys(v).length === 0)
            throw new Error("api-metadata.json has not been included in browser-polyfill");
          class S extends WeakMap {
            constructor(r, a = void 0) {
              super(a), this.createItem = r;
            }
            get(r) {
              return this.has(r) || this.set(r, this.createItem(r)), super.get(r);
            }
          }
          const L = (e) => e && typeof e == "object" && typeof e.then == "function", j = (e, r) => (...a) => {
            u.runtime.lastError ? e.reject(new Error(u.runtime.lastError.message)) : r.singleCallbackArg || a.length <= 1 && r.singleCallbackArg !== !1 ? e.resolve(a[0]) : e.resolve(a);
          }, w = (e) => e == 1 ? "argument" : "arguments", _ = (e, r) => function(a, ...t) {
            if (t.length < r.minArgs)
              throw new Error(`Expected at least ${r.minArgs} ${w(r.minArgs)} for ${e}(), got ${t.length}`);
            if (t.length > r.maxArgs)
              throw new Error(`Expected at most ${r.maxArgs} ${w(r.maxArgs)} for ${e}(), got ${t.length}`);
            return new Promise((A, o) => {
              if (r.fallbackToNoCallback)
                try {
                  a[e](...t, j({
                    resolve: A,
                    reject: o
                  }, r));
                } catch (l) {
                  console.warn(`${e} API method doesn't seem to support the callback parameter, falling back to call it without a callback: `, l), a[e](...t), r.fallbackToNoCallback = !1, r.noCallback = !0, A();
                }
              else r.noCallback ? (a[e](...t), A()) : a[e](...t, j({
                resolve: A,
                reject: o
              }, r));
            });
          }, N = (e, r, a) => new Proxy(r, {
            apply(t, A, o) {
              return a.call(A, e, ...o);
            }
          });
          let y = Function.call.bind(Object.prototype.hasOwnProperty);
          const k = (e, r = {}, a = {}) => {
            let t = /* @__PURE__ */ Object.create(null), A = {
              has(l, s) {
                return s in e || s in t;
              },
              get(l, s, d) {
                if (s in t)
                  return t[s];
                if (!(s in e))
                  return;
                let n = e[s];
                if (typeof n == "function")
                  if (typeof r[s] == "function")
                    n = N(e, e[s], r[s]);
                  else if (y(a, s)) {
                    let x = _(s, a[s]);
                    n = N(e, e[s], x);
                  } else
                    n = n.bind(e);
                else if (typeof n == "object" && n !== null && (y(r, s) || y(a, s)))
                  n = k(n, r[s], a[s]);
                else if (y(a, "*"))
                  n = k(n, r[s], a["*"]);
                else
                  return Object.defineProperty(t, s, {
                    configurable: !0,
                    enumerable: !0,
                    get() {
                      return e[s];
                    },
                    set(x) {
                      e[s] = x;
                    }
                  }), n;
                return t[s] = n, n;
              },
              set(l, s, d, n) {
                return s in t ? t[s] = d : e[s] = d, !0;
              },
              defineProperty(l, s, d) {
                return Reflect.defineProperty(t, s, d);
              },
              deleteProperty(l, s) {
                return Reflect.deleteProperty(t, s);
              }
            }, o = Object.create(e);
            return new Proxy(o, A);
          }, T = (e) => ({
            addListener(r, a, ...t) {
              r.addListener(e.get(a), ...t);
            },
            hasListener(r, a) {
              return r.hasListener(e.get(a));
            },
            removeListener(r, a) {
              r.removeListener(e.get(a));
            }
          }), F = new S((e) => typeof e != "function" ? e : function(r) {
            const a = k(r, {}, {
              getContent: {
                minArgs: 0,
                maxArgs: 0
              }
            });
            e(a);
          }), M = new S((e) => typeof e != "function" ? e : function(r, a, t) {
            let A = !1, o, l = new Promise((x) => {
              o = function(c) {
                A = !0, x(c);
              };
            }), s;
            try {
              s = e(r, a, o);
            } catch (x) {
              s = Promise.reject(x);
            }
            const d = s !== !0 && L(s);
            return s !== !0 && !d && !A ? !1 : (((x) => {
              x.then((c) => {
                t(c);
              }, (c) => {
                let P;
                c && (c instanceof Error || typeof c.message == "string") ? P = c.message : P = "An unexpected error occurred", t({
                  __mozWebExtensionPolyfillReject__: !0,
                  message: P
                });
              }).catch((c) => {
                console.error("Failed to send onMessage rejected reply", c);
              });
            })(d ? s : l), !0);
          }), B = ({
            reject: e,
            resolve: r
          }, a) => {
            u.runtime.lastError ? u.runtime.lastError.message === f ? r() : e(new Error(u.runtime.lastError.message)) : a && a.__mozWebExtensionPolyfillReject__ ? e(new Error(a.message)) : r(a);
          }, $ = (e, r, a, ...t) => {
            if (t.length < r.minArgs)
              throw new Error(`Expected at least ${r.minArgs} ${w(r.minArgs)} for ${e}(), got ${t.length}`);
            if (t.length > r.maxArgs)
              throw new Error(`Expected at most ${r.maxArgs} ${w(r.maxArgs)} for ${e}(), got ${t.length}`);
            return new Promise((A, o) => {
              const l = B.bind(null, {
                resolve: A,
                reject: o
              });
              t.push(l), a.sendMessage(...t);
            });
          }, I = {
            devtools: {
              network: {
                onRequestFinished: T(F)
              }
            },
            runtime: {
              onMessage: T(M),
              onMessageExternal: T(M),
              sendMessage: $.bind(null, "sendMessage", {
                minArgs: 1,
                maxArgs: 3
              })
            },
            tabs: {
              sendMessage: $.bind(null, "sendMessage", {
                minArgs: 2,
                maxArgs: 3
              })
            }
          }, C = {
            clear: {
              minArgs: 1,
              maxArgs: 1
            },
            get: {
              minArgs: 1,
              maxArgs: 1
            },
            set: {
              minArgs: 1,
              maxArgs: 1
            }
          };
          return v.privacy = {
            network: {
              "*": C
            },
            services: {
              "*": C
            },
            websites: {
              "*": C
            }
          }, k(u, I, v);
        };
        i.exports = p(chrome);
      }
    });
  }(E)), E.exports;
}
var W = U();
const b = /* @__PURE__ */ q(W), h = async ({ title: g }) => {
  let m;
  g ? m = { title: g } : m = { active: !0, lastFocusedWindow: !0 };
  const [i] = await b.tabs.query(m);
  if (!i)
    throw new Error("未查询到对应的标签页！");
  return { id: i.id, title: i.title };
}, D = async ({ url: g }) => {
  await b.tabs.create({
    url: g
  });
}, Z = async ({ title: g }) => {
  const m = await h({ title: g });
  await b.tabs.reload(m.id, { bypassCache: !0 });
}, z = async ({ title: g }) => {
  const m = await h({ title: g });
  await b.tabs.remove(m.id);
}, J = async ({ title: g }) => {
  const m = await h({ title: g });
  await b.tabs.update(m.id, { active: !0 });
}, V = async ({ selector: g, title: m }) => {
  const i = await h({ title: m });
  return await b.tabs.sendMessage(i.id, { selector: g });
}, H = async () => {
  const g = [], m = await b.tabs.query({});
  for (let i of m)
    g.push({ id: i.id, title: i.title });
  return g;
}, G = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  createTab: D,
  getEle: V,
  getTab: h,
  getTabs: H,
  reloadTab: Z,
  removeTab: z,
  switchTab: J
}, Symbol.toStringTag, { value: "Module" }));
b.runtime.onMessage.addListener((g, m, i) => {
  const f = JSON.parse(g);
  return G[f.key](f.params).then((p) => {
    i(JSON.stringify(p));
  }).catch((p) => {
    const u = { code: "10001", msg: p.message };
    i(JSON.stringify(u));
  }), !0;
});
